<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:33:"./themes/admin/dp/expert_add.html";i:1746431983;s:51:"/lysoo/syzth.lysoo.com/syzth/themes/admin/base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
<style>
    font {
        color: #cc0000;
    }
</style>

    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class=""><a href="<?php echo url('admin/dp/expert'); ?>">师资团队</a></li>
                <li class="layui-this">添加师资</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="<?php echo url('admin/dp/save_expert'); ?>" method="post">
                        <div class="layui-form-item">
                            <label class="layui-form-label">师资姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" required lay-verify="required" placeholder="请输入专家姓名" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">师资介绍</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入介绍" name="desc" class="layui-textarea"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">师资图片</label>
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" id="uploadBtn">上传图片</button>
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" id="previewImg" width="100" height="100">
                                    <input type="hidden" name="img" id="img" value="">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="submitExpert">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['form', 'upload'], function(){
        var form = layui.form, upload = layui.upload;

        // 图片上传
        var uploadInst = upload.render({
            elem: '#uploadBtn',
            url: '/index/index/upload', // 修改为你上传接口的实际地址
            before: function(obj){
                obj.preview(function(index, file, result){
                    $('#previewImg').attr('src', result); // 图片预览
                });
            },
            done: function(res){
                if(res.code === 1){
                    $('#img').val(res.data.url);
                }
                layer.msg(res.msg);
            },
            error: function(){
                layer.msg('上传失败，请重试');
            }
        });

        // 表单提交（AJAX方式）
        form.on('submit(submitExpert)', function(data){
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                data: $(data.form).serialize(),
                success: function(info){
                    if(info.code === 1){
                        setTimeout(function(){
                            window.location.href = "<?php echo url('admin/dp/expert'); ?>";
                        }, 1000);
                    }
                    layer.msg(info.msg);
                }
            });
            return false;
        });
    });
</script>

<!--页面JS脚本-->
</body>
</html>

